package cd826dong.cloud.zuul;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.EnableZuulServer;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;

/**
 * @author ZHOUTIEQIANG053
 *当Zuul路由服务将客户端请求转发到具体服务时，Zuul会使用
HystrixCommand来包装这些执行过程，所以之前我们在Hystrix章节中
所讲到的配置及服务容错机制，对于Zuul的请求执行都是适用的，也
会影响到API服务网关的行为
 */
@EnableZuulProxy
@SpringBootApplication
public class Application {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}


	//自定义路由规则,hc-serivce形式的url，变成service/hc的形式访问
	@Bean
	public PatternServiceRouteMapper serviceRouteMapper() {
		return new PatternServiceRouteMapper(
				"(?<hc>^.+)-(?<service>.+$)",
				"${service}/${hc}");
	}
}
